<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<script th:inline="javascript">
	/*$("select[name='[(${fieldNo})]']").change(function() {
		onPaperNoCtlChange();
	});

	$("select[name='[(${fieldYear})]']").change(function() {
		onPaperNoCtlChange();
	});*/

	function initPaperNoFieldChange() {
		var oldValue = ""; // 一个不存在的值
		var sint = setInterval(function(){
			if (fo("[(${fieldNo})]")) {
				if (oldValue != fo("[(${fieldNo})]").value) {
					oldValue = fo("[(${fieldNo})]").value;
					onPaperNoCtlChange();
				}
			} else {
				window.clearInterval(sint);
			}
		},500);

		getCurFormUtil().addInterval(sint, "[(${formName})]");

		var oldValueYear = ""; // 一个不存在的值
		var sintYear = setInterval(function(){
			if (fo("[(${fieldYear})]")) {
				if (oldValueYear != fo("[(${fieldYear})]").value) {
					oldValueYear = fo("[(${fieldYear})]").value;
					onPaperNoCtlChange();
				}
			} else {
				window.clearInterval(sintYear);
			}
		},500);

		getCurFormUtil().addInterval(sintYear, "[(${formName})]");
	}
	initPaperNoFieldChange();

	function onPaperNoCtlChange() {
		if (fo("[(${fieldNo})]") && fo("[(${fieldNo})]").value=="") {
			fo("[(${fieldName})]").value = "";
			return;
		}

		// 查看详情时
		if (!fo("[(${fieldNo})]").value || !fo("[(${fieldYear})]").value) {
			return;
		}

		var ajaxData = {
			op: "getNo",
			flowId: "[(${flowId})]",
			fieldName: "[(${fieldName})]",
			[(${fieldNo})]: fo("[(${fieldNo})]").value,
			[(${fieldYear})]: fo("[(${fieldYear})]").value,
		};
		ajaxPost('/flow/macro/getPaperno', ajaxData).then((res) => {
			console.log('res', res);
			if (res.code == 200) {
				findObj("[(${fieldName})]").value = res.data.num;
			} else {
				myMsg(res.msg, 'warn');
			}
		});
	}
</script>
</body>
</html>